package zust.study.java8feature.lambda;

import java.util.Arrays;
import java.util.List;

public class Demo03_Sort {
    public static void main(String[] args) {

        //String
        String[] newWay = "Improving code with Lambda expressions in Java 8".split(" ");
        Arrays.sort(newWay, (s1, s2) -> {
            return s1.toLowerCase().compareTo(s2.toLowerCase());
        });
        System.out.println(String.join(", ", newWay));

        //Integer
        Integer[] nums = {1, 2, 6, 10, 3, 9};
        Arrays.sort(nums, (s1, s2) -> {
            return s1.compareTo(s2);
        });

        List<Integer> numList = Arrays.asList(nums);
        numList.sort((a, b) -> {
            return b.compareTo(a);
        });
        numList.forEach(n -> System.out.println(n));

    }
}
